
#include "core/global.h"

Settings::Settings():
    QSettings("data/config.ini", QSettings::IniFormat)
{
    setDefault("window/language", "en");

    setDefault("game/userName", "Unknown");
    setDefault("game/serverIPAddress", "127.0.0.1");
    setDefault("game/serverName", value("game/userName").toString() + "'s Server");
    setDefault("game/serverPort", 12134);
    setDefault("game/playerNum", 2);

    setDefault("game/ruleOdd", true);
    setDefault("game/ruleEven", false);

    if(!value("game/ruleOdd").toBool() && !value("game/ruleEven").toBool()){
        setValue("game/ruleEven", true);
    }
}

void Settings::setDefault(const QString &key, const QVariant &value){
    if(!contains(key)){
        setValue(key, value);
    }
}

Settings Config;
